/* AI Design Studio - 全局样式系统 */

:root {
  /* 主色 */
  --primary-black: #1A1A1A;
  --primary-blue: #3B82F6;
  --primary-purple: #8B5CF6;
  
  /* 背景色 */
  --bg-white: #FFFFFF;
  --bg-gray-50: #FAFBFC;
  --bg-gray-100: #F3F4F6;
  --bg-gray-200: #E5E7EB;
  --bg-sidebar: #FAFAFA;
  
  /* 文本色 */
  --text-primary: #1A1A1A;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  
  /* 边框色 */
  --border-light: #E8E8E8;
  --border-medium: #D1D5DB;
  --border-focus: #3B82F6;
  
  /* 阴影 */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 16px rgba(0,0,0,0.10);
  --shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
  --shadow-active: 0 4px 12px rgba(26,26,26,0.15);
  --shadow-focus: 0 0 0 3px rgba(59,130,246,0.1);
  --shadow-navbar: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 覆盖Blueprint.js深色主题，改为亮色主题 */
body {
  background-color: var(--bg-white) !important;
}

body.bp5-dark {
  background-color: var(--bg-white) !important;
}

/* 主容器布局 - CSS Grid实现 */
.ai-studio-container {
  display: grid;
  grid-template-columns: 72px 1fr 400px;
  grid-template-rows: 64px 1fr 48px;
  grid-template-areas:
    "header header header"
    "sidebar canvas panel"
    "footer footer footer";
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  position: relative;
}

/* 添加微妙的背景纹理 */
.ai-studio-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(255, 255, 255, 0.05) 35px, rgba(255, 255, 255, 0.05) 70px);
  pointer-events: none;
  z-index: 1;
}

/* 顶部导航栏 */
.ai-studio-navbar {
  grid-area: header;
  height: 64px;
  background-color: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-navbar);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
}

.ai-studio-navbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ai-studio-logo {
  width: 32px;
  height: 32px;
  background-color: var(--primary-black);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.ai-studio-project-name {
  font-size: 15px;
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 500;
}

.ai-studio-navbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-studio-nav-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background-color: transparent;
  border: none;
  color: #525252;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  font-size: 18px;
}

.ai-studio-nav-button:hover {
  background-color: var(--bg-gray-100);
  color: var(--primary-black);
}

/* 左侧工具栏 - 优化后的样式 */
.ai-studio-toolbar {
  grid-area: sidebar;
  width: 72px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
}

/* 工具按钮 - 圆形设计 */
.ai-studio-tool-button {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  background-color: var(--bg-white);
  border: 1.5px solid var(--border-light);
  color: #525252;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  font-size: 20px;
  position: relative;
  outline: none;
  box-sizing: border-box;
}

/* 悬停效果 */
.ai-studio-tool-button:hover {
  background-color: var(--bg-white);
  border-color: var(--primary-black);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}

/* 激活状态 */
.ai-studio-tool-button.active {
  background-color: var(--primary-black);
  color: white;
  border-color: var(--primary-black);
  box-shadow: var(--shadow-active);
}

/* 工具提示 */
.ai-studio-tool-button:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: rgba(26, 26, 26, 0.9);
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  animation: tooltipFadeIn 0.2s ease 0.5s forwards;
  z-index: 1000;
}

@keyframes tooltipFadeIn {
  to {
    opacity: 1;
  }
}

/* 中央画布区域 */
.ai-studio-canvas {
  grid-area: canvas;
  background: #ffffff;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
  z-index: 10;
}

/* 画布内部网格背景（可选） */
.ai-studio-canvas-grid {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(240, 240, 240, 0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 240, 240, 0.3) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
  opacity: 0.5;
}

/* 右侧AI面板 */
.ai-studio-ai-panel {
  grid-area: panel;
  width: 400px;
  background-color: var(--bg-gray-50);
  border-left: 1px solid var(--border-light);
  padding: 24px;
  overflow-y: auto;
  z-index: 50;
}

.ai-panel-avatar {
  width: 56px;
  height: 56px;
  background-color: var(--primary-black);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: white;
  font-size: 24px;
}

.ai-panel-greeting {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.ai-panel-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 24px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.ai-panel-input {
  width: 100%;
  min-height: 120px;
  padding: 16px;
  background-color: var(--bg-white);
  border: 1.5px solid var(--border-medium);
  border-radius: 12px;
  font-size: 15px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  resize: vertical;
  transition: all 0.2s ease;
  outline: none;
}

.ai-panel-input::placeholder {
  color: var(--text-tertiary);
}

.ai-panel-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.ai-panel-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  margin-bottom: 32px;
}

.ai-panel-action-button {
  width: 36px;
  height: 36px;
  background-color: var(--bg-gray-100);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  font-size: 18px;
}

.ai-panel-action-button:hover {
  background-color: var(--bg-gray-200);
}

.ai-panel-template {
  background-color: var(--bg-white);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}

.ai-panel-template:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.ai-panel-template-image {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background-color: var(--bg-gray-100);
}

.ai-panel-template-content {
  padding: 16px;
}

.ai-panel-template-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.ai-panel-template-description {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* 底部工具栏 */
.ai-studio-footer {
  grid-area: footer;
  height: 48px;
  background-color: var(--bg-white);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
}

.ai-studio-footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-studio-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-studio-footer-button {
  padding: 6px 12px;
  background-color: var(--bg-gray-100);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-primary);
  transition: all 0.2s ease;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.ai-studio-footer-button:hover {
  background-color: var(--bg-gray-200);
}

/* 响应式断点 */
@media screen and (max-width: 1279px) {
  .ai-studio-container {
    grid-template-columns: 64px 1fr 360px;
  }
  
  .ai-studio-ai-panel {
    width: 360px;
  }
  
  .ai-studio-toolbar {
    width: 64px;
  }
}

@media screen and (max-width: 1023px) {
  .ai-studio-container {
    grid-template-columns: 56px 1fr;
    grid-template-areas:
      "header header"
      "sidebar canvas"
      "footer footer";
  }
  
  .ai-studio-ai-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    height: 50vh;
    width: 100%;
    transform: translateY(calc(100% - 48px));
    transition: transform 0.3s ease;
    border-left: none;
    border-top: 1px solid var(--border-light);
  }
  
  .ai-studio-ai-panel.open {
    transform: translateY(0);
  }
  
  .ai-studio-toolbar {
    width: 56px;
  }
}

/* 覆盖Polotno默认样式 */
.polotno-app-container {
  background-color: var(--bg-white) !important;
}

.polotno-side-panel {
  background-color: var(--bg-sidebar) !important;
  width: 72px !important;
  border-right: 1px solid var(--border-light) !important;
}

.polotno-workspace-container {
  background-color: var(--bg-white) !important;
}

/* 清除Blueprint深色主题样式 */
.bp5-dark, .bp5-navbar.bp5-dark, body.bp5-dark {
  background-color: transparent !important;
}

.bp5-dark .bp5-navbar {
  background-color: var(--bg-white) !important;
  border-bottom: 1px solid var(--border-light) !important;
  box-shadow: var(--shadow-navbar) !important;
}

.bp5-dark .bp5-button {
  background-color: transparent !important;
  box-shadow: none !important;
  color: var(--text-primary) !important;
}

.bp5-dark .bp5-editable-text {
  color: var(--text-primary) !important;
}

/* 字体加载 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif !important;
}